function Combox_Type() {
	$.ajax({
		type : "POST",
		url : "../TitleTypeController/findByCondition.action",
		data : null,
		success : function(data) {
			var html = "<option value=''>-请选择-</option>";
			$.each(JSON.parse(data), function(j, o) {
				html += '<option value="' + o.titleTypeid + '">' + o.titleTypename
						+ '</option>';
			});
			$("#TitleCombox").html(html);
			$("#TitleCombox1").html(html);
		},
		error : function(request) {
			toastr.error("多选框错误!");
		}
	});
}
function Combox_Dictionary() {
	$.ajax({
		type : "POST",
		url : "../DictionaryController/findByCondition.action",
		data : {
			"dictionaryType":"题目难度",
		},
		success : function(data) {
			var html = "<option value=''>-请选择-</option>";
			$.each(JSON.parse(data), function(j, o) {
				html += '<option value="' + o.dictionaryKey + '">' + o.dictionaryValue
						+ '</option>';
			});
			$("#DictionaryCombox").html(html);
			$("#DictionaryCombox1").html(html);
			
		},
		error : function(request) {
			toastr.error("多选框错误!");
		}
	});
}

function Combox_Dictionary_Type() {
	$.ajax({
		type : "POST",
		url : "../DictionaryController/findByCondition.action",
		data : {
			"dictionaryType":"题目题型",
		},
		success : function(data) {
		 
			var html = "<option value=''>-请选择-</option>";
			$.each(JSON.parse(data), function(j, o) {
				html += '<option value="' + o.dictionaryKey + '">' + o.dictionaryValue
						+ '</option>';
			});
			$("#Combox_Dictionary_Type").html(html);
			
			$("#Combox_Dictionary_Type1").html(html);
		},
		error : function(request) {
			toastr.error("多选框错误!");
		}
	});
}
function queryParams(params) {
	
	return {
		titleName: $('#titleName').val(),
		titleTypeid:$("#TitleCombox").val(),
		extend2:$('#Combox_Dictionary_Type').val(),
		extend1:$('#DictionaryCombox').val(),
	};
}

//通过ID插到类型名称
function findTitleContent(data1) {
    var a="";
	$.ajax({
		type : "POST",
		url : "../TitleTypeController/findByCondition.action",
		async : false,
		data :  
		{
			"titleTypeid": data1,
		},
		success : function(d) {	
			var obj = eval('(' + d + ')');	
			a=a+obj[0].titleTypename;
		},
		
	});
  return '<a  style="width:60px; dislpay:inline;overflow:hidden; white-space:nowrap;color:#CD8500">'+a+'</a>';
}


$('#reset').click(function() {
		 $('#titleName').val(""),
		 $("#TitleCombox").val(""),
		 $('#Combox_Dictionary_Type').val(""),
		 $('#DictionaryCombox').val(""),
		 $('#Title').bootstrapTable('refresh', {url: '../TitleController/findByCondition.action'});  
		 
});
function getScore(x){
		      var f = parseFloat(x);   
		      if (isNaN(f)) {   
		        return false;   
		      }   
		      var f = Math.round(x*100)/100;   
		      var s = f.toString();   
		      var rs = s.indexOf('.');   
		      if (rs < 0) {   
		        rs = s.length;   
		        s += '.';   
		      }   
		      while (s.length <= rs + 2) {   
		        s += '0';   
		      }   
		      return s;   
		    }  

$(function() {
	Combox_Type();
	Combox_Dictionary();
	Combox_Dictionary_Type();
	$("#TitleForm").validate({
		rules: {			
			titleName:"required",
			titleTypeid:"required",
		
		},
		errorPlacement: function (label, element) {
            $(element).tooltip('destroy'); /*必需*/
            $(element).attr('title', $(label).text()).tooltip('show'); 
        },
	});
/*	Combox("Title",{id:"titleId",name:"titleName",width:"100%"},{"deleteState":0});*/
	init('Title',600,500,"titleId","题目");

});